package ${package}<#if moduleName??>.${moduleName}</#if>.controller<#if subModuleName??>.${subModuleName}</#if>;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

import com.alibaba.fastjson.JSONObject;

import com.xisoft.core.product.utils.ErrorMessage;
import com.xisoft.core.product.utils.PubResult;
import ${package}<#if moduleName??>.${moduleName}</#if>.service<#if subModuleName??>.${subModuleName}.${className}Service</#if>;

/**
 * 自动生成：${tableComments}Controller
 * @author 作者：👨🏻${author} 📧${email} ☎13121055201
 * @description 类描述：${tableComments}
 * @create 创建时间：${date}
 * @update 修改时间：${date}
 * @since ${version} ${date}
 */
@RestController
@RequestMapping("<#if moduleName??>${moduleName}/</#if>${className}")
public class ${className}Controller
{

    @Qualifier ("${className}ServiceImpl")
    @Autowired
    private ${className}Service service;
    
    private static Logger log = (Logger) LoggerFactory.getLogger(${className}Controller.class);

    @ResponseBody
    @RequestMapping (value = "/Save", method = RequestMethod.POST)
    public PubResult Save(@RequestBody String jsonStr) throws Exception
    {
        PubResult result = new PubResult();
        try
        {
            log.info("调用${className}Controller的Save方法：" + jsonStr);
            if (StringUtils.isEmpty(jsonStr))
            { throw new IllegalArgumentException(ErrorMessage.PARAM_IS_NULL_OR_EMPTY.getDesc()); }
            result = service.billSave(JSONObject.parseObject(jsonStr));
        }
        catch (Exception e)
        {
            log.error("调用${className}Controller的Save方法异常：" + e.toString());
            e.printStackTrace();
            throw new Exception(e.getMessage());
        }
        
        return result;
    }

    @ResponseBody
    @RequestMapping (value = "/Delete", method = RequestMethod.POST)
    public PubResult Delete(@RequestBody String jsonStr) throws Exception
    {
        PubResult result = new PubResult();
        try
        {
            log.info("调用${className}Controller的Delete方法：" + jsonStr);
            if (StringUtils.isEmpty(jsonStr))
            { throw new IllegalArgumentException(ErrorMessage.PARAM_IS_NULL_OR_EMPTY.getDesc()); }
            result = service.billDelete(JSONObject.parseObject(jsonStr));
        }
        catch (Exception e)
        {
            log.error("调用${className}Controller的Delete方法异常：" + e.toString());
            e.printStackTrace();
            throw new Exception(e.getMessage());
        }
        
        return result;
    }

    @ResponseBody
    @RequestMapping (value = "/Update", method = RequestMethod.POST)
    public PubResult Update(@RequestBody String jsonStr) throws Exception
    {
        PubResult result = new PubResult();
        try
        {
            log.info("调用${className}Controller的Update方法：" + jsonStr);
            if (StringUtils.isEmpty(jsonStr))
            { throw new IllegalArgumentException(ErrorMessage.PARAM_IS_NULL_OR_EMPTY.getDesc()); }
            result = service.billUpdate(JSONObject.parseObject(jsonStr));
        }
        catch (Exception e)
        {
            log.error("调用${className}Controller的Update方法：" + e.toString());
            e.printStackTrace();
            throw new Exception(e.getMessage());
        }
        
        return result;
    }

    @ResponseBody
    @RequestMapping (value = "/Query", method = RequestMethod.POST)
    public PubResult Query(@RequestBody String jsonStr) throws Exception
    {
        PubResult result = new PubResult();
        try
        {
            log.info("调用${className}Controller的Query方法：" + jsonStr);
            if (StringUtils.isEmpty(jsonStr))
            { throw new IllegalArgumentException(ErrorMessage.PARAM_IS_NULL_OR_EMPTY.getDesc()); }
            result = service.billQuery(JSONObject.parseObject(jsonStr));
        }
        catch (Exception e)
        {
            log.error("调用${className}Controller的Query方法异常：" + e.toString());
            e.printStackTrace();
            throw new Exception(e.getMessage());
        }
        
        return result;
    }

    @ResponseBody
    @RequestMapping (value = "/QueryConfig", method = RequestMethod.POST)
    public PubResult QueryConfig(@RequestBody String jsonStr) throws Exception
    {
        PubResult result = new PubResult();
        try
        {
            log.info("调用${className}Controller的QueryConfig方法：" + jsonStr);
            if (StringUtils.isEmpty(jsonStr))
            { throw new IllegalArgumentException(ErrorMessage.PARAM_IS_NULL_OR_EMPTY.getDesc()); }
            result = service.billConfig(JSONObject.parseObject(jsonStr));
        }
        catch (Exception e)
        {
            log.error("调用${className}Controller的QueryConfig方法异常：" + e.toString());
            e.printStackTrace();
            throw new Exception(e.getMessage());
        }
        
        return result;
    }

    @ResponseBody
    @RequestMapping (value = "/DataSource", method = RequestMethod.POST)
    public PubResult queryDataSources(@RequestBody String jsonStr) throws Exception
    {
        PubResult result = new PubResult();
        try
        {
            log.info("调用${className}Controller的DataSource方法：" + jsonStr);
            if (StringUtils.isEmpty(jsonStr))
            { throw new IllegalArgumentException(ErrorMessage.PARAM_IS_NULL_OR_EMPTY.getDesc()); }
            result = service.billDataSource(JSONObject.parseObject(jsonStr));
        }
        catch (Exception e)
        {
            log.error("调用${className}Controller的DataSource方法异常：" + e.toString());
            e.printStackTrace();
            throw new Exception(e.getMessage());
        }
        
        return result;
    }
}